# -*- coding:utf-8 -*-
__author__ = 'Forcs'

from django.db import models
from wancake.models.base.models import BaseModel

import wancake.config as wc_config

'''
EPG数据库表模型映射

注释格式 数据库.表
'''

class EpgModel(BaseModel):
    epg_id = models.BigIntegerField(null=True)

    class Meta:
        abstract = True
        app_label = wc_config.DATABASE

class EpgOrderRecord(EpgModel):
    """
    epg_release_sync.order_record
    """
    user_id = models.CharField(max_length=32, null=True)
    product_id = models.CharField(max_length=32, null=True)
    product_name = models.CharField(max_length=64, null=True)
    order_type = models.IntegerField(null=True)
    amount = models.IntegerField(null=True, default=0)
    subscribe_time = models.DateTimeField(null=True)
    unsubscribe_time = models.DateTimeField(null=True)
    expired_time = models.DateTimeField(null=True)
    order_status = models.IntegerField(null=True, default=0)
    user_mobile = models.CharField(max_length=32, null=True)
    subscribe_source = models.IntegerField(null=True, default=0)
    unsubscribe_source = models.IntegerField(null=True, default=0)
    last_sync_time = models.DateTimeField(null=True)
    sd_or_hd = models.CharField(max_length=2, null=True)


class EpgStatisCategory(EpgModel):
    """
    epg_release_sync.statis_category
    """
    cate_name = models.CharField(max_length=256, null=True)
    cate_code = models.CharField(max_length=256, null=True)
    content_name = models.CharField(max_length=256, null=True)
    content_code = models.CharField(max_length=256, null=True)
    seconds = models.BigIntegerField(null=True)
    seconds_str = models.CharField(max_length=256, null=True)
    pv_count = models.BigIntegerField(null=True)
    stb_count = models.BigIntegerField(null=True)
    create_time = models.DateTimeField(null=True)
    update_time = models.DateTimeField(null=True)
    sd_or_hd = models.CharField(max_length=2, null=True)
    play_date = models.DateTimeField(null=True)
    play_date_str = models.CharField(max_length=256, null=True)
    pv_valid_count = models.BigIntegerField(null=True)
    pv_invalid_count = models.BigIntegerField(null=True)


class EpgSysCpProducts(EpgModel):
    """
    epg_release_sync.sys_cp_products
    """
    product_id = models.BigIntegerField(null=True)
    product_name = models.CharField(max_length=256, null=True)
    product_price = models.BigIntegerField(null=True)
    sp_id = models.BigIntegerField(null=True)
    is_platform_pack = models.IntegerField(null=True)


class EpgSysOrganization(EpgModel):
    """
    epg_release_sync.sys_organization
    """
    org_code = models.CharField(max_length=128, null=True)
    org_name = models.CharField(max_length=64, null=True)
    org_type = models.IntegerField(null=True)
    path = models.CharField(max_length=256, null=True)
    parent_id = models.IntegerField(null=True)


class EpgTaskJob(EpgModel):
    """
    epg_release_sync.task_job
    """
    class_name = models.CharField(max_length=256, null=True)
    create_time = models.DateTimeField(null=True)
    job_desc = models.TextField(null=True)
    job_name = models.CharField(max_length=256, null=True)
    method_name = models.CharField(max_length=256, null=True)


class EpgUserCateStatis(EpgModel):
    """
    epg_release_sync.user_cate_statis
    """
    cate_code = models.CharField(max_length=32, null=True)
    cate_name = models.CharField(max_length=32, null=True)
    play_times = models.BigIntegerField(null=True)


class EpgUserPlayDaily(EpgModel):
    """
    epg_release_sync.user_play_daily
    """
    date_str = models.CharField(max_length=64, null=True)
    seconds = models.IntegerField(null=True)
    main_id = models.CharField(max_length=32, null=True)
    user_id = models.CharField(max_length=64, null=True)
    user_name = models.CharField(max_length=64, null=True)
    play_mode = models.IntegerField(null=True)
    sd_or_hd = models.CharField(max_length=2, null=True)
    nickname = models.CharField(max_length=32, null=True)
    nickname_web = models.CharField(max_length=32, null=True)
    mood = models.IntegerField(null=True)
    has_signin = models.CharField(max_length=10, null=True)


class EpgUserPlayDetail(EpgModel):
    """
    epg_release_sync.user_play_detail
    """
    date_str = models.CharField(max_length=32, null=True)
    cate_code = models.CharField(max_length=256, null=True)
    last_video_time = models.IntegerField(null=True)
    begin_time = models.DateTimeField(null=True)
    end_time = models.DateTimeField(null=True)
    seconds = models.IntegerField(null=True)
    main_id = models.CharField(max_length=64, null=True)
    user_id = models.CharField(max_length=64, null=True)
    user_name = models.CharField(max_length=128, null=True)
    item_code = models.CharField(max_length=256, null=True)
    play_mode = models.IntegerField(null=True)
    video_name = models.CharField(max_length=128, null=True)
    sd_or_hd = models.CharField(max_length=2, null=True)


class EpgUserPlayInfo(EpgModel):
    """
    epg_release_sync.user_play_info
    """
    user_id = models.CharField(max_length=256, null=True)
    u_id = models.BigIntegerField(null=True)
    create_time = models.DateTimeField(null=True)
    sd_or_hd = models.CharField(max_length=2, null=True)
    epg_group = models.CharField(max_length=8, null=True)
    nickname = models.CharField(max_length=32, null=True)
    nickname_web = models.CharField(max_length=32, null=True)
    age = models.CharField(max_length=32, null=True)
    sex = models.CharField(max_length=32, null=True)


class EpgUserPlayTotal(EpgModel):
    """
    epg_release_sync.user_play_total
    """
    seconds = models.IntegerField(null=True)
    today_seconds = models.BigIntegerField(null=True)
    before_seconds = models.BigIntegerField(null=True)
    user_id = models.CharField(max_length=256, null=True)
    update_time = models.DateTimeField(null=True)
    sd_or_hd = models.CharField(max_length=2, null=True)
    nickname = models.CharField(max_length=32, null=True)
    nickname_web = models.CharField(max_length=32, null=True)


class EpgWanbaDailyOrderStat(EpgModel):
    """
    epg_release_sync.wanba_daily_order_stat
    """
    daily_date = models.DateTimeField(null=True)
    product_id = models.CharField(max_length=256, null=True)
    product_name = models.CharField(max_length=256, null=True)
    sub_num_sd = models.BigIntegerField(null=True)
    unsub_num_sd = models.BigIntegerField(null=True)
    sub_num_hd = models.BigIntegerField(null=True)
    unsub_num_hd = models.BigIntegerField(null=True)


class EpgWanbaDailyStatis(EpgModel):
    """
    epg_release_sync.wanba_daily_statis
    """
    daily_date = models.DateTimeField(null=True)
    pv_count = models.BigIntegerField(null=True)
    stb_count = models.BigIntegerField(null=True)
    joined_user = models.BigIntegerField(null=True)
    total_joined_user = models.BigIntegerField(null=True)
    active_users = models.BigIntegerField(null=True)
    total_users = models.BigIntegerField(null=True)
    new_users = models.BigIntegerField(null=True)
    wanba_pack_order_num = models.BigIntegerField(null=True)
    other_pack_order_num = models.BigIntegerField(null=True)
    comment_num = models.BigIntegerField(null=True)
    category_code = models.CharField(max_length=256, null=True)
    sd_pv_count = models.BigIntegerField(null=True)
    sd_stb_count = models.BigIntegerField(null=True)
    sd_joined_user = models.BigIntegerField(null=True)
    sd_total_joined_user = models.BigIntegerField(null=True)
    sd_active_users = models.BigIntegerField(null=True)
    sd_total_users = models.BigIntegerField(null=True)
    sd_new_users = models.BigIntegerField(null=True)
    sd_wanba_pack_order_num = models.BigIntegerField(null=True)
    sd_other_pack_order_num = models.BigIntegerField(null=True)
    sd_comment_num = models.BigIntegerField(null=True)
    sd_category_code = models.CharField(max_length=256, null=True)
    dog_tv_num = models.BigIntegerField(null=True)
    dog_bar_num = models.BigIntegerField(null=True)
    sd_dog_tv_num = models.BigIntegerField(null=True)
    sd_dog_bar_num = models.BigIntegerField(null=True)


class EpgWanbaUserAccount(EpgModel):
    """
    epg_release_sync.wanba_user_account
    """
    user_id = models.CharField(max_length=256, null=True)
    create_time = models.DateTimeField(null=True)
    last_visit_time = models.DateTimeField(null=True)
    priv_visit_time = models.DateTimeField(null=True)
    platform = models.CharField(max_length=16, null=True, default='sd')


class EpgSyncRecord(BaseModel):
    """
    用于记录Epg同步数据
    """
    last_id = models.BigIntegerField(null=True)
    column_name = models.CharField(max_length=64, null=True)
    table_name = models.CharField(max_length=64, null=True, unique=True)
    sync_datetime = models.DateTimeField(null=True)
